<template>
  <div class="header">
    <div :class="['header_item',{ 'active': activeTitle === title }]" v-for="title, index in pannelTitles" @click="changeHeader(title)">
      {{ title }}
    </div>
  </div>
</template>

<script setup>
import { onMounted, ref, watch } from 'vue';
import { useTitleStore } from '../store/title'
import { storeToRefs } from 'pinia'
import { cdConfig } from '@/components/layComponents/index'
const store = useTitleStore()
const { changeTitle } = store
const { activeTitle } = storeToRefs(store)
const pannelTitles = Object.keys(cdConfig)
const changeHeader = (title) => {
  changeTitle(title)
}
onMounted(() => {
  changeTitle(pannelTitles[0])
})
</script>

<style lang="less" scoped>
.header {
  display: flex;
  align-items: center;
  font-size: 40px;
  width: 100%;
  height: 200px;
  justify-content: space-around;
  background-color: antiquewhite;
  .header_item {
    &.active, &:hover {
      color: red;
      cursor: pointer;
    }
  }
}
</style>